package com.tjsinfo.tjsoa.mail.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.mail.bo.TjsEmailFolderBo;
import com.tjsinfo.tjsoa.mail.bo.TjsMailBo;
import com.tjsinfo.tjsoa.mail.vo.TjsEmailFolder;
import com.tjsinfo.tjsoa.mail.vo.Tjsmail;
/**
 * 回复邮件FROM
 * @author wangxiaowei
 *
 */
public class BackMailFromAction extends Action{
	private TjsMailBo tjsMailBo;
	private TjsEmailFolderBo tjsEmailFolderBo;
	public TjsMailBo getTjsMailBo() {
		return tjsMailBo;
	}
	public void setTjsMailBo(TjsMailBo tjsMailBo) {
		this.tjsMailBo = tjsMailBo;
	}
	public TjsEmailFolderBo getTjsEmailFolderBo() {
		return tjsEmailFolderBo;
	}
	public void setTjsEmailFolderBo(TjsEmailFolderBo tjsEmailFolderBo) {
		this.tjsEmailFolderBo = tjsEmailFolderBo;
	}
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		try {
			//String id =  request.getParameter("id");
			//List<Tjsmail> list = tjsMailBo.selectByID(id);//已发送邮件列表
			//if (list.size() > 0) {
				//Tjsmail tjsmail = list.get(0);
				Tjsmail tjsmail=tjsMailBo.selectOneId(request.getParameter("id"));
				request.setAttribute("tjsmail", tjsmail);
				List<TjsEmailFolder> list = tjsEmailFolderBo.selectByUserId(SessionUser.getUserId(request));//文件夹邮件
				request.setAttribute("foldlist", list);
				return mapping.findForward("ok");
			/*} else {
				return mapping.findForward("error");
			}*/
		} catch (RuntimeException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return mapping.findForward("error");
		}
		
	}
	
}
